package com.shujia.wyh.day10;

import java.util.ArrayList;

/*
    集合的嵌套遍历
 */
public class ArrayListTest3 {
    public static void main(String[] args) {
        //数加有4个班级 21期，22期，23期，24期  ArrayList<Student>
        ArrayList<ArrayList<Student>> shujia = new ArrayList<>();

        //创建4个期
        ArrayList<Student> clazz21 = new ArrayList<>();
        Student s1 = new Student("张三", 16);
        Student s2 = new Student("李四", 17);
        clazz21.add(s1);
        clazz21.add(s2);
        shujia.add(clazz21);

        ArrayList<Student> clazz22 = new ArrayList<>();
        Student s11 = new Student("王五", 17);
        Student s12 = new Student("王二麻", 19);
        clazz22.add(s11);
        clazz22.add(s12);
        shujia.add(clazz22);

        ArrayList<Student> clazz23 = new ArrayList<>();
        Student s31 = new Student("王辉煌", 19);
        Student s32 = new Student("吴涛", 17);
        Student s33 = new Student("陈涛", 20);
        clazz23.add(s31);
        clazz23.add(s32);
        clazz23.add(s33);
        shujia.add(clazz23);


        for (ArrayList<Student> clazz : shujia) {
            for (Student student : clazz) {
                System.out.println(student);
            }
            System.out.println("===============================");
        }


    }
}
